home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / grep.zip / GREP.DOC < prev    next >
Text File  |  1993-01-04  |  2KB  |  44 lines

  1. grep searches a file for a given pattern.  Execute by
  2.    grep [flags] regular_expression file_list
  3.  
  4. Flags are single characters preceeded by '-':
  5.    -c      Only a count of matching lines is printed
  6.    -f      Print file name for matching lines switch, see below
  7.    -n      Each line is preceeded by its line number
  8.    -v      Only print non-matching lines
  9.  
  10. The file_list is a list of files (wildcards are acceptable on RSX modes).
  11.  
  12. The file name is normally printed if there is a file given.
  13. The -f flag reverses this action (print name no file, not if more).
  14.  
  15. The regular_expression defines the pattern to search for.  Upper- and
  16. lower-case are always ignored.  Blank lines never match.  The expression
  17. should be quoted to prevent file-name translation.
  18. x      An ordinary character (not mentioned below) matches that character.
  19. '\'    The backslash quotes any character.  "\$" matches a dollar-sign.
  20. '^'    A circumflex at the beginning of an expression matches the
  21.        beginning of a line.
  22. '$'    A dollar-sign at the end of an expression matches the end of a line.
  23. '.'    A period matches any character except "new-line".
  24. ':a'   A colon matches a class of characters described by the following
  25. ':d'     character.  ":a" matches any alphabetic, ":d" matches digits,
  26. ':n'     ":n" matches alphanumerics, ": " matches spaces, tabs, and
  27. ': '     other control characters, such as new-line.
  28. '*'    An expression followed by an asterisk matches zero or more
  29.        occurrances of that expression: "fo*" matches "f", "fo"
  30.        "foo", etc.
  31. '+'    An expression followed by a plus sign matches one or more
  32.        occurrances of that expression: "fo+" matches "fo", etc.
  33. '-'    An expression followed by a minus sign optionally matches
  34.        the expression.
  35. '[]'   A string enclosed in square brackets matches any character in
  36.        that string, but no others.  If the first character in the
  37.        string is a circumflex, the expression matches any character
  38.        except "new-line" and the characters in the string.  For
  39.        example, "[xyz]" matches "xx" and "zyx", while "[^xyz]"
  40.        matches "abc" but not "axb".  A range of characters may be
  41.        specified by two characters separated by "-".  Note that,
  42.        [a-z] matches alphabetics, while [z-a] never matches.
  43. The concatenation of regular expressions is a regular expression.
  44.